package com.zz.service;

import com.zz.dao.UserMapper;
import com.zz.pojo.User;
import com.zz.pojo.UserExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(String userName, String passWord) {
        UserExample example=new UserExample();
        UserExample.Criteria criteria = example.createCriteria();
        criteria.andUsenameEqualTo(userName);
        criteria.andPasswordEqualTo(passWord);
        List<User> users = userMapper.selectByExample(example);
        if (users!=null&&users.size()>0){
            return users.get(0);
        }
        return null;
    }
}
